<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8" />
	<meta http-equiv="content-Type" content="text/html;charset=utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

	<meta name="description" content="同乡烩后台管理系统" />
	<title>同乡烩后台管理系统</title>
	<link rel="stylesheet" th:href="@{css/bootstrap.min.css}">
	<link rel="stylesheet" th:href="@{css/reset.css}" />
	<link rel="stylesheet" th:href="@{css/main.css}" />
	<link rel="stylesheet" th:href="@{css/list.css}" />
	<script type="text/javascript" th:src="@{js/jquery-3.4.1.js}"></script>
	<script th:src="@{js/bootstrap.min.js}"></script>
	<!--<script type="text/javascript">
		let currentpage;
		$(function () {
			var body_height = $(document).height();
			$(".main").css("height", body_height + "px")
			$("#caipin").empty();

			$.ajax({
				type:"get",
				url:"dishes/findallDishes.do?pageNum=1",
				dataType:"json",
				success:function (data){
					$.each(data,function (i,n){
						$("#caipin").append("<div class='section section2'><div class='margin-right-container-nav margin-right-container-nav2'>" +
								"<img src='images/"+n.image+"'>" +
								"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.name+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.sales+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.price+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'><a id='change' onclick='modifyDi("+n.foodid+")'>修改</a>/<a id='remove' onclick='deleteDi("+n.foodid+")'>删除</a></div>" +
								"<div class='clear'></div></div>")
					})
				}
			})

		})
		function deleteDi(obj) {
			if(confirm("是否删除")){
				$.ajax({
					type: "get",
					url: "dishes/deleteDish.do",
					data:{
						"id":obj
					},
					dataType: "json",
					success:function (data){
						if(data.result==1){
							alert("删除成功");
							window.location.reload();
						}else {
							alert("删除失败，请检查网络");
						}
					}
				})
				return true;
			}else {
				return false;
			}
		}
		function fenye(obj){
			currentpage=obj;
			$("#caipin").empty();
			$.ajax({
				type:"get",
				url:"dishes/findallDishes.do",
				data:{
					"pageNum":obj
				},
				dataType:"json",
				success:function (data){
					$.each(data,function (i,n){
						$("#caipin").append("<div class='section section2'><div class='margin-right-container-nav margin-right-container-nav2'>" +
								"<img src='images/"+n.image+"'>" +
								"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.name+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.sales+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'>"+n.price+"</div>" +
								"<div class='margin-right-container-nav margin-right-container-nav2'><a id='change' onclick='modifyDi("+n.foodid+")'>修改</a>/<a id='remove' onclick='deleteDi("+n.foodid+")'>删除</a></div>" +
								"<div class='clear'></div></div>")
					})
				}
			})
		}
	</script>-->
</head>
<!-- 菜品列表 -->
<body>
<!-- 固定 -->
<div class="main">
	<div th:replace="admin/admin-left::left"/>
	<div class="main-left"></div>

	<!-- 操作 -->
	<div class="main-right">
		<div class="main-right-header"></div>
		<div class="main-right-navs">
			<a href="#">管理首页</a><a class="split">/</a><a>菜品管理</a><a>/</a><a>菜品列表</a>
			<!-- 搜索模块 -->
			<div class="search">
				<input type="search" id="search" name="search" placeholder="请输入具体名称" required/>
				<button id="searchIn" type="submit"></button>
			</div>
			<script>
				$("#searchIn").click(function () {
					let para = {
						search: $("#search").val()
					}
					$.ajax({
						url: "/toSearchDishes",
						type: "post",
						data: para,
						dataType: "html",
						success: function (data) {
							eval(data)
						}
					})
				})
			</script>
		</div>

		<div class="margin-right-container">
			<div class="section section1">
				<div class="margin-right-container-nav">图片</div>
				<div class="margin-right-container-nav">菜品名称</div>
				<div class="margin-right-container-nav">月销量</div>
				<div class="margin-right-container-nav">价格</div>
				<div class="margin-right-container-nav">操作</div>
				<div class="clear"></div>
			</div>

			<div id="caipin">
			<div class="section  section2" th:each="dishes:${dishes}">
				<div class="margin-right-container-nav margin-right-container-nav2">
					<img th:src="@{images/}+${dishes.getImage()}" />
				</div>
				<div class="margin-right-container-nav margin-right-container-nav2" th:text="${dishes.getName()}">菜名</div>
				<div class="margin-right-container-nav margin-right-container-nav2" th:text="${dishes.getSales()}">销量</div>
				<div class="margin-right-container-nav margin-right-container-nav2" th:text="${dishes.getPrice()}">999</div>
				<div class="margin-right-container-nav margin-right-container-nav2"><a id="change" th:href="@{/toUpdateDishes/}+${dishes.getFoodid()}">修改</a>/<a
						id="remove" th:href="@{/deleteDishes/}+${dishes.getFoodid()}">删除</a></div>
				<div class="clear"></div>
			</div>
			</div>
		</div>

		<!--<div id="pagination">
		<nav aria-label="Page navigation">
			<ul class="pagination">
				<li>
					<a href="#" aria-label="Previous">
						<span aria-hidden="true" id="previous">上一页</span>
					</a>
				</li>
				<li><a href="#" onclick="fenye(1)">1</a></li>
				<li><a href="#" onclick="fenye(2)">2</a></li>
				<li><a href="#" onclick="fenye(3)">3</a></li>
				<li><a href="#" onclick="fenye(4)">4</a></li>
				<li><a href="#" onclick="fenye(5)">5</a></li>
				<li>
					<a href="#" aria-label="Next">
						<span aria-hidden="true" id="next">下一页</span>
					</a>
				</li>
				<span id="txt"></span>
			</ul>

		</nav>
		</div>-->
	</div>

</div>
</body>
</html>
